Skip to main content

Operator List

Arithmetic Operators

SyntaxDescriptionOperator CategoryOperator Concept
a + bAdditionstdatem.operator.arithmetic.binaryAddition
a +& bOverflowing Additionstdatem.operator.arithmetic.binaryOverflowingAddition
a +\| bSaturating Additionstdatem.operator.arithmetic.binarySaturatingAddition
a - bSubtractionstdatem.operator.arithmetic.binarySubtraction
a -&= bOverflowing Subtractionstdatem.operator.arithmetic.binaryOverflowingSubtraction
a -\| bSaturating Subtractionstdatem.operator.arithmetic.binarySaturatingSubtraction
a * bMultiplicationstdatem.operator.arithmetic.binaryMultiplication
a *& bOverflowing Multiplicationstdatem.operator.arithmetic.binaryOverflowingMultiplication
a *\| bSaturating Multiplicationstdatem.operator.arithmetic.binarySaturatingMultiplication
a / b Divisionstdatem.operator.arithmetic.binaryDivision
a % bRemainder Divisionstdatem.operator.arithmetic.binaryRemainderDivision
-aNegationstdatem.operator.arithmetic.unaryNegation
-&aOverflowing Negationstdatem.operator.arithmetic.unaryOverflowingNegation
a ** bPowerstdatem.operator.arithmetic.binaryPower
a **& bOverflowing Powerstdatem.operator.arithmetic.binaryOverflowingPower
a **\| bSaturating Powerstdatem.operator.arithmetic.binarySaturatingPower

Assignment Operators

SyntaxDescriptionOperator CategoryOperator Concept
a = bSimple Assignmentstdatem.operator.assignment.binaryAssignment
a += bAddition Assignmentstdatem.operator.assignment.binaryAdditionAssignment
a +&= bOverflowing Addition Assignmentstdatem.operator.assignment.binaryOverflowingAdditionAssignment
a +\|= bSaturating Addition Assignmentstdatem.operator.assignment.binarySaturatingAdditionAssignment
a -= bSubtraction Assignmentstdatem.operator.assignment.binarySubtractionAssignment
a -&= bOverflowing Subtraction Assignmentstdatem.operator.assignment.binaryOverflowingSubtractionAssignment
a -\|= bSaturating Subtraction Assignmentstdatem.operator.assignment.binarySaturatingSubtractionAssignment
a *= bMultiplication Assignmentstdatem.operator.assignment.binaryMultiplicationAssignment
a *&= bOverflowing Multiplication Assignmentstdatem.operator.assignment.binaryOverflowingMultiplicationAssignment
a *\|= bSaturating Multiplication Assignmentstdatem.operator.assignment.binarySaturatingMultiplicationAssignment
a /= bDivision Assignmentstdatem.operator.assignment.binaryDivisionAssignmentAssignment
a %= bRemainder Division Assignmentstdatem.operator.assignment.binaryRemainderDivisionAssignment
a **= bPower Assignmentstdatem.operator.assignment.binaryPowerAssignment
a **&= bOverflowing Power Assignmentstdatem.operator.assignment.binaryOverflowingPowerAssignment
a **\|= bSaturating Power Assignmentstdatem.operator.assignment.binarySaturatingPowerAssignment
<<=Bitwise Left Shift Assignmentstdatem.operator.assignment.binaryBitwiseLeftShiftAssignment
<<\|=Saturating Bitwise Left Shift Assignmentstdatem.operator.assignment.binarySaturatingBitwiseLeftShiftAssignment
>>=Bitwise Right Shift Assignmentstdatem.operator.assignment.binaryBitwiseRightShiftAssignment
&=Bitwise AND Assignmentstdatem.operator.assignment.binaryBitwiseAndAssignment
\|=Bitwise OR Assignmentstdatem.operator.assignment.binaryBitwiseOrAssignment
~=Bitwise NOT Assignmentstdatem.operator.assignment.binaryBitwiseNotAssignment

Comparison Operators

SyntaxDescriptionOperator CategoryOperator Concept
a > bGreater thanstdatem.operator.comparison.binaryGreaterThan
a < bLess thanstdatem.operator.comparison.binaryLessThan
a >= bGreater than or Equal tostdatem.operator.comparison.binaryGreaterThanOrEqual
a <= bLess than or Equal tostdatem.operator.comparison.binaryLessThanOrEqual
a != bNot Equal tostdatem.operator.comparison.binaryNotEqual
a == bEqual tostdatem.operator.comparison.binaryEqual
a <=> bThree-way Comparisonstdatem.operator.comparison.binaryThreeWayComparison

Logical Operators

SyntaxDescriptionOperator CategoryOperator Concept
not aLogical NOTstdatem.operator.logical.unaryLogicalNot
a and bLogical ANDstdatem.operator.logical.binaryLogicalAnd
a or bLogical ORstdatem.operator.logical.binaryLogicalOr

Bitwise Operators

SyntaxDescriptionOperator CategoryOperator Concept
~aBitwise NOTstdatem.operator.bitwise.unaryBitwiseNot
a & bBitwise ANDstdatem.operator.bitwise.binaryBitwiseAnd
a \| bBitwise ORstdatem.operator.bitwise.binaryBitwiseOr
a ^ bBitwise XORstdatem.operator.bitwise.binaryBitwiseXor
a << bBitwise Left Shiftstdatem.operator.bitwise.binaryBitwiseLeftShift
a <<\| bSaturating Bitwise Left Shiftstdatem.operator.bitwise.binarySaturatingBitwiseLeftShift
a >> bBitwise Right Shiftstdatem.operator.bitwise.binaryBitwiseRightShift

Pointer Operators

SyntaxDescriptionOperator CategoryOperator Concept
TypeA.&Pointer Typestdatem.operator.pointer.unaryN/A
pointer_a.*Pointer Dereferencestdatem.operator.pointer.unaryN/A
a.@Object Addressstdatem.operator.pointer.unaryN/A

Reflection Operators

SyntaxDescriptionOperator CategoryOperator Concept
^aReflectionstdatem.operator.reflection.unaryN/A
#aReificationstdatem.operator.reflection.unaryN/A

Range Operators

SyntaxDescriptionOperator CategoryOperator Concept
a...bClosed Rangestdatem.operator.range.binaryClosedRange
a..<bHalf-opened Rangestdatem.operator.range.binaryHalfOpenedRange
a<..bHalf-opened Rangestdatem.operator.range.binaryHalfOpenedRange
a<.<bOpened Rangestdatem.operator.range.binaryOpenedRange
...aOne-sided Rangestdatem.operator.range.unaryOneSidedRange
a...One-sided Rangestdatem.operator.range.unaryOneSidedRange

Optional Operators

SyntaxDescriptionOperator CategoryOperator Concept
a ?? bUnwrapping with Default Valuestdatem.operator.optional.binaryUnwrapping
a.?Throwable Unwrapping, equivalent to a ?? throw UnwrapExceptionstdatem.operator.optional.unaryUnwrapping
a.!Forced Unwrapping, equivalent to a ?? unreachablestdatem.operator.optional.unaryUnwrapping
a?.bThrowable Optional Chainingstdatem.operator.optional.binaryUnwrapping
a!.bForced Optional Chainingstdatem.operator.optional.binaryUnwrapping

Other Operators

SyntaxDescriptionOperator CategoryOperator Concept
a as TypeBType Castingstdatem.operator.misc.binaryAs
a as? TypeBOptional Type Castingstdatem.operator.misc.binaryAs
a as! TypeBForced Type Castingstdatem.operator.misc.binaryAs
TypeA is TypeBType Queryingstdatem.operator.misc.binaryIs
a.bMember Accessstdatem.operator.misc.binaryMemberAccess
a[b]Array Element Accessstdatem.operator.misc.binaryArrayElementAccess
a.[b]Tuple Value Element Accessstdatem.operator.misc.binaryTupleValueAccess
a::[b]Tuple Type Element Accessstdatem.operator.misc.binaryTupleTypeAccess
new TypeAMemory Allocationstdatem.operator.misc.unaryNew
delete aMemory Deallocationstdatem.operator.misc.unaryDelete
?TypeAOptional Typestdatem.operator.misc.unaryN/A
dyn TypeAType-erased Typestdatem.operator.misc.unaryN/A
a~bTypestdatem.operator.misc.binaryN/A